Create a report with static maps and interactive graphs that is meant to be read by others (e.g.Β your friends and family). Hide warnings, messages and even the code you used so that it is readable. Included references. Link to the Lab 10 report from your Github site. Submit the link to Moodle. animations that is meant to be read by others (e.g.Β your friends and family). Hide warnings, messages and even the code you used so that it is readable. Included references. Link to the Lab 6 report from your Github site. Submit the link to Moodle.

All data was retrieved from the GitHub Repo for Novel Coronavirus (COVID-19) Cases (Dong, Du, and Gardner 2020).

Lab 6 - Data Maps, Interactive Graphs and Animations from the COVID-19 reporting data

Challenge Exercises

Challenge Exercise 1

Challenge Exercise 2

Update Anisa Dhana’s graph layout of the US to 9/26/2020. You may need to adjust the size of the points.

library(tidyverse)

daily_report <-   read_csv(url("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/09-26-2020.csv")) %>% 
  rename(Long = "Long_") %>% 
  filter(Country_Region == "US") %>% 
  filter (!Province_State %in% c("Alaska","Hawaii", "American Samoa",
                  "Puerto Rico","Northern Mariana Islands", 
                  "Virgin Islands", "Recovered", "Guam", "Grand Princess",
                  "District of Columbia", "Diamond Princess")) %>% 
  filter(Lat > 0)

head(daily_report)
## # A tibble: 6 x 14
##    FIPS Admin2 Province_State Country_Region Last_Update           Lat  Long
##   <dbl> <chr>  <chr>          <chr>          <dttm>              <dbl> <dbl>
## 1  1001 Autau… Alabama        US             2020-09-27 04:23:00  32.5 -86.6
## 2  1003 Baldw… Alabama        US             2020-09-27 04:23:00  30.7 -87.7
## 3  1005 Barbo… Alabama        US             2020-09-27 04:23:00  31.9 -85.4
## 4  1007 Bibb   Alabama        US             2020-09-27 04:23:00  33.0 -87.1
## 5  1009 Blount Alabama        US             2020-09-27 04:23:00  34.0 -86.6
## 6  1011 Bullo… Alabama        US             2020-09-27 04:23:00  32.1 -85.7
## # … with 7 more variables: Confirmed <dbl>, Deaths <dbl>, Recovered <dbl>,
## #   Active <dbl>, Combined_Key <chr>, Incidence_Rate <dbl>,
## #   `Case-Fatality_Ratio` <dbl>
library(ggplot2)

mybreaks <- c(1, 100, 1000, 10000, 100000)
ggplot(daily_report, aes(x = Long, y = Lat, size = Confirmed)) +
    borders("state", colour = "white", fill = "grey90") +
    geom_point(aes(x=Long, y=Lat, size=Confirmed, color=Confirmed),stroke=F, alpha=0.7) +
    scale_size_continuous(name="Cases", trans="log", range=c(1,7), 
                        breaks=mybreaks, labels = c("1-99", "100-999", "1,000-9,999", "10,000-99,999", "100,000+")) +
    scale_color_viridis_c(option="viridis",name="Cases",
                        trans="log", breaks=mybreaks, labels = c("1-99", "100-999", "1,000-9,999", "10,000-99,999", "100,000+"))  +
  theme_void() + 
    guides( colour = guide_legend()) +
    labs(title = "COVID-19 Confirmed Cases in the US'") +
    theme(
      legend.position = "bottom",
      text = element_text(color = "#22211d"),
      plot.background = element_rect(fill = "#ffffff", color = NA), 
      panel.background = element_rect(fill = "#ffffff", color = NA), 
      legend.background = element_rect(fill = "#ffffff", color = NA),
      plot.title = element_text(face="bold", hjust=0.5)
    ) +
    coord_fixed(ratio=1.5)
## Warning: Transformation introduced infinite values in discrete y-axis

## Warning: Transformation introduced infinite values in discrete y-axis
## Warning in sqrt(x): NaNs produced
## Warning: Removed 6 rows containing missing values (geom_point).

Challenge Exercise 3

Update the graph β€œNumber of Confirmed Cases by US County” to 9/26/2020 and use a different color scheme or theme

# Get and format the covid report data
report_09_26_2020 <-   read_csv(url("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/09-26-2020.csv")) %>% 
  rename(Long = "Long_") %>% 
  unite(Key, Admin2, Province_State, sep = ".") %>% 
  group_by(Key) %>% 
  summarize(Confirmed = sum(Confirmed)) %>% 
  mutate(Key = tolower(Key))

# dim(report_03_27_2020)
# get and format the map data
us <- map_data("state")
counties <- map_data("county") %>% 
  unite(Key, subregion, region, sep = ".", remove = FALSE)

# Join the 2 tibbles
state_join <- left_join(counties, report_09_26_2020, by = c("Key"))
# sum(is.na(state_join$Confirmed))
options(scipen=999)

library(ggplot2)
library(RColorBrewer)
# To display only colorblind-friendly brewer palettes, specify the option colorblindFriendly = TRUE as follow:
# display.brewer.all(colorblindFriendly = TRUE)

ggplot(data = us, mapping = aes(x = long, y = lat, group = group)) + 
  coord_fixed(1.3) +
  borders("state", colour = "black") +
  geom_polygon(data = state_join, aes(fill = Confirmed)) +
  scale_fill_gradientn(colors = brewer.pal(n = 5, name = "BuPu"),
                       breaks = c(1, 10, 100, 1000, 10000, 100000, 1000000),
                       trans = "log10", na.value = "White") +
  ggtitle("Number of Confirmed Cases by US County") +
  theme_linedraw() +
  theme(panel.grid=element_blank(),
        plot.title=element_text(face="bold", hjust=0.5))
## Warning: Transformation introduced infinite values in discrete y-axis

Challenge Exercise 4

Make an interactive plot using a state of your chosing using a theme different from used in the above examples.

daily_report <-   read_csv(url("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/09-26-2020.csv")) %>% 
  rename(Long = "Long_") %>% 
  filter(Province_State == "Washington") %>% 
  group_by(Admin2) %>% 
  summarize(Confirmed = sum(Confirmed)) %>% 
  mutate(Admin2 = tolower(Admin2))
us <- map_data("state")
wa_us <- subset(us, region == "washington")
counties <- map_data("county")
wa_county <- subset(counties, region == "washington")
state_join <- left_join(wa_county, daily_report, by = c("subregion" = "Admin2")) 
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
ggplotly(
  ggplot(data = wa_county, mapping = aes(x = long, y = lat, group = group)) + 
  coord_fixed(1.3) + 
# Add data layer
  geom_polygon(data = state_join, aes(fill = Confirmed), color = "black") +
    scale_fill_gradientn(colours = wes_palette("Royal1", 100, type = "continuous")) +
  ggtitle("COVID-19 Cases in WA") +
# Cleaning up the graph
  labs(x=NULL, y=NULL) +
  theme(panel.border = element_blank()) +
  theme(panel.background = element_blank()) +
  theme(axis.ticks = element_blank()) +
  theme(axis.text = element_blank()) +
  theme(plot.title = element_text(face="bold"))
)

Dong, Ensheng, Hongru Du, and Lauren Gardner. 2020. β€œAn Interactive Web-Based Dashboard to Track COVID-19 in Real Time.” The Lancet Infectious Diseases 20 (5). Elsevier: 533–34. https://doi.org/10.1016/S1473-3099(20)30120-1.